//
//  ADJgSDKInterstitialCustomEvent.m
//  AnyThinkSDKDemo
//
//  Created by 刘娟 on 2024/9/25.
//  Copyright © 2024 抽筋的灯. All rights reserved.
//

#import "ADJgSDKInterstitialCustomEvent.h"

@implementation ADJgSDKInterstitialCustomEvent
- (void)loadInterstitialAdWithPosId:(NSString *)posId{
    self.interstitialAdContainer = [[ADJgSDKInterstitialAdContainer alloc] initPosId:posId delegate:self];
    [self.interstitialAdContainer loadInterstitialAd];
}
- (void)showInterstitialAdAdWithRootViewController:(UIViewController *)controller{
    if(self.isReady){
        [self.interstitialAdContainer showInterstitialAdWithRootViewController:controller];
    }
}

/**
 ADJgSDKIntertitialAd请求成功回调
 
 @param interstitialAd 插屏广告实例对象
*/
- (void)adjg_interstitialAdSuccedToLoad:(ADJgSDKIntertitialAd *)interstitialAd{
    self.isReady = YES;
    [self trackInterstitialAdLoaded:self.interstitialAdContainer adExtra:nil];
}

/**
 ADJgSDKIntertitialAd请求失败回调

 @param interstitialAd 插屏广告实例对象
 @param error 失败原因
*/
- (void)adjg_interstitialAdFailedToLoad:(ADJgSDKIntertitialAd *)interstitialAd error:(ADJgAdapterErrorDefine *)error{
    [_interstitialAdContainer close];
    [self trackInterstitialAdLoadFailed:nil];
}

/**
 ADJgSDKIntertitialAd展示在屏幕内回调

 @param interstitialAd 插屏广告实例对象
*/
- (void)adjg_interstitialAdDidPresent:(ADJgSDKIntertitialAd *)interstitialAd{
    
}

/**
 ADJgSDKIntertitialAd展示在屏幕内失败回调

 @param interstitialAd 插屏广告实例对象
*/
- (void)adjg_interstitialAdFailedToPresent:(ADJgSDKIntertitialAd *)interstitialAd error:(NSError *)error{
    [_interstitialAdContainer close];
    [self trackInterstitialAdShowFailed:nil];
}

/**
 ADJgSDKIntertitialAd点击回调

 @param interstitialAd 插屏广告实例对象
*/
- (void)adjg_interstitialAdDidClick:(ADJgSDKIntertitialAd *)interstitialAd{
    [self trackInterstitialAdClick];
}

/**
 ADJgSDKIntertitialAd关闭回调

 @param interstitialAd 插屏广告实例对象
*/
- (void)adjg_interstitialAdDidClose:(ADJgSDKIntertitialAd *)interstitialAd{
    [_interstitialAdContainer close];
    [self trackInterstitialAdClose:nil];
}

/**
 ADJgSDKIntertitialAd展示回调
 
 @param interstitialAd 广告实例
 */
- (void)adjg_interstitialAdExposure:(ADJgSDKIntertitialAd *)interstitialAd{
    [self trackInterstitialAdShow];
}

/**
 ADJgSDKIntertitialAd关闭落地页回调
 
 @param interstitialAd 广告实例
 */
- (void)adjg_interstitialAdCloseLandingPage:(ADJgSDKIntertitialAd *)interstitialAd{
    [_interstitialAdContainer close];
    [self trackInterstitialAdClose:nil];
}

- (NSString *)networkUnitId {
    return self.serverInfo[@"slot_id"];
}

@end
